class HouseItem:
    def __init__(self, name, area):
        self.name = name
        self.area = area


class House:
    def __init__(self, unit_type, total_area, remaining_area, furnitures):
        self.unit_type = unit_type
        self.total_area = total_area
        self.remaining_area = remaining_area
        self.furnitures = furnitures
        self.furnitures = [HouseItem('None', 0)]

    def add_furniture(self, house_item):
        if self.furnitures[0].name == 'None':
            self.furnitures.pop()
        if house_item.area > self.remaining_area:
            print('remaining area is not enough to set {}'.format(house_item.name))
        else:
            self.remaining_area -= house_item.area
            self.furnitures.append(house_item)

    def show_house(self):
        print('unit type is {}'.format(self.unit_type))
        print('total area is {}'.format(self.total_area))
        print('remaining area is {}'.format(self.remaining_area))
        index = 1 if self.furnitures[0].name != 'None' else 0
        for furniture in self.furnitures:
            print('{}.{}'.format(index, furniture.name))
            index += 1
    #  最好使用__str__，因为可以直接print(object)


h = House('type1', 45, 45, None)
bed = HouseItem('bed', 4)
h.add_furniture(bed)
chest = HouseItem('chest', 2)
h.add_furniture(chest)
table = HouseItem('table', 1.5)
h.add_furniture(table)

h.show_house()
